
package tests;

import java.util.logging.*;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import cz.czu.pef.DataModelling.data.BasicGardeningData;
import cz.czu.pef.DataModelling.utils.Constants;

@Component(value="getBasicData")
//@ContextConfiguration(locations={"classpath:appContext-test.xml"})
public class GetBasicData
{
	public static Logger logger = Logger.getLogger(GetBasicData.class.getName());

	@Autowired BasicGardeningData basicGardeningData;
	ApplicationContext applicationContext;

	public static void main(String[] args)
	{
		(new GetBasicData()).doTest();
	}

	@Transactional
	public void doTest()
	{
		try
		{
			applicationContext = new ClassPathXmlApplicationContext(Constants.springTestingClasspathConfig);

		  basicGardeningData = (BasicGardeningData)applicationContext.getBean("basicGardeningData");
			//applicationContext.getAutowireCapableBeanFactory().autowireBean(fillBasicGardeningData);

		  basicGardeningData.getSomeData();
		}
		catch (InstantiationException e)
		{
			e.printStackTrace();
		}
		catch (IllegalAccessException e)
		{
			e.printStackTrace();
		}

		logger.log(Level.INFO, "Test passed");
	}
}
